home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / eXec / Pokazac obrazek / datatype2.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  3KB  |  111 lines

  1. /* Îadowanie i wyôwietlanie obrazka przez datatypes.library  - przykîad 2 */
  2. /* Grzegorz "Krashan" Kraszewski, eXec */
  3.  
  4.  
  5. #define __NOLIBBASE__
  6.  
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/intuition.h>
  10. #include <proto/datatypes.h>
  11. #include <proto/graphics.h>
  12. #include <datatypes/pictureclass.h>
  13.  
  14.  
  15. struct Library *SysBase, *IntuitionBase, *DataTypesBase, *GfxBase;
  16.  
  17.  
  18. BOOL OpenLibs (void)
  19.  {
  20.   if (!(IntuitionBase = OpenLibrary ("intuition.library", 39))) return FALSE;
  21.   if (!(DataTypesBase = OpenLibrary ("datatypes.library", 39))) return FALSE;
  22.   if (!(GfxBase = OpenLibrary ("graphics.library", 39))) return FALSE;
  23.   return TRUE;
  24.  }
  25.  
  26.  
  27. void CloseLibs (void)
  28.  {
  29.   if (DataTypesBase) CloseLibrary (DataTypesBase);
  30.   if (IntuitionBase) CloseLibrary (IntuitionBase);
  31.   if (GfxBase) CloseLibrary (GfxBase);
  32.   return;
  33.  }
  34.  
  35.  
  36. int main (void)
  37.  {
  38.   BOOL ok = TRUE;
  39.   Object *picture;
  40.   LONG width, height;
  41.   struct Window *okno;
  42.  
  43.   if (ok = OpenLibs ())
  44.    {
  45.     if (picture = NewDTObject ("PROGDIR:obrazek", DTA_GroupID, GID_PICTURE,
  46.      PDTA_Remap, TRUE, TAG_END))
  47.      {
  48.      GetDTAttrs (picture,
  49.        DTA_NominalHoriz,       (LONG)&width,
  50.        DTA_NominalVert,        (LONG)&height,
  51.        TAG_END);
  52.  
  53.       if (okno = OpenWindowTags (NULL,
  54.        WA_InnerWidth,     width,
  55.        WA_InnerHeight,    height,
  56.        WA_DragBar,        TRUE,
  57.        WA_CloseGadget,    TRUE,
  58.        WA_Activate,       TRUE,
  59.        WA_SmartRefresh,   TRUE,
  60.        WA_IDCMP,          IDCMP_CLOSEWINDOW,
  61.        WA_Title,          (LONG)"Przykîad 2",
  62.        TAG_END))
  63.        {
  64.         struct IntuiMessage *msg;
  65.         struct BitMap *bm;
  66.         LONG msgclass;
  67.         BOOL run = TRUE;
  68.  
  69.         /* Poniûsza linia to jedyna róûnica w stosunku do wersji 1 */
  70.  
  71.         SetDTAttrs (picture, NULL, NULL, PDTA_Screen, (LONG)okno->WScreen,
  72.          TAG_END);
  73.  
  74.         /* ------------------------------------------------------- */
  75.  
  76.         DoDTMethod (picture, NULL, NULL, DTM_PROCLAYOUT, NULL, DTSIF_NEWSIZE);
  77.         GetDTAttrs (picture, PDTA_DestBitMap, (LONG)&bm, TAG_END);
  78.  
  79.         if (bm) BltBitMapRastPort (bm, 0, 0, okno->RPort, okno->BorderLeft,
  80.          okno->BorderTop, width, height, 0xC0);
  81.  
  82.         while (run)
  83.          {
  84.           WaitPort (okno->UserPort);
  85.           while (msg = (struct IntuiMessage*)GetMsg (okno->UserPort))
  86.            {
  87.             msgclass = msg->Class;
  88.             ReplyMsg ((struct Message*)msg);
  89.             if (msgclass == IDCMP_CLOSEWINDOW) run = FALSE;
  90.            }
  91.          }
  92.  
  93.         CloseWindow (okno);
  94.        }
  95.  
  96.       DisposeDTObject (picture);
  97.      }
  98.     else ok = FALSE;
  99.    }
  100.   CloseLibs ();
  101.  
  102.   if (ok) return 0;
  103.   else
  104.    {
  105.     printf ("bîâd\n");
  106.     return 10;
  107.    }
  108.  }
  109.  
  110.  
  111.